package com.kust.smarthome.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kust.smarthome.web.mapper.DetectorMapper;
import com.kust.smarthome.web.model.Detector;
import com.kust.smarthome.web.service.IDetectorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author iAuzre
 * @since 2021-06-28
 */
@Service
public class DetectorServiceImpl extends ServiceImpl<DetectorMapper, Detector> implements IDetectorService {

    @Autowired
    private DetectorMapper detectorMapper;

    @Override
    public int insert(Detector detector) {
        detectorMapper.insert(detector);
        return detector.getId();
    }

    @Override
    public List<Detector> getByUserId(Integer id) {
        QueryWrapper<Detector> query = new QueryWrapper<>();
        query.eq("user_id",id);
        return detectorMapper.selectList(query);
    }
}
